home *** CD-ROM | disk | FTP | other *** search
- Path: news.nynexst.com!rcn
- From: rcn@east (Ramesh Nagabushnam)
- Newsgroups: comp.lang.c++
- Subject: Re: How do you reset a file?
- Date: 3 Apr 1996 23:35:08 GMT
- Organization: NYNEX Science & Technology, Inc
- Message-ID: <4jv1vc$ha1@news.nynexst.com>
- References: <3162b143.399039@news.airmail.net>
- NNTP-Posting-Host: east.nynexst.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Elizabeth Cunningham (liz@iadfw.net) wrote:
- : This might be a stupid question, but I couldn't find the answer in
- : either of the C++ books I have. How do you reset an fstream object
- : back to the beginning of the file?
-
- Your question could be interpreted >= 2 ways
-
- 1) You just want to move the file pointer:
-
- fstream fobj(..);
-
- fobj.seekpos(0,mode); // see man filebuf
-
- 2) You wish to truncate the file:
-
- fstream fobj(..);
-
- ftruncate(fobj.fd(),0); // see man ftruncate(), man filebuf
-
- -r
- ____________________________________________________
- Ramesh Nagabushnam, (o) (914) 644-2711
- rcn@nynexst.com (h) (203) 967-1129
-